//
//  UIBarButtonItem+Extension.swift
//  micro_blog
//
//  Created by Mac on 16/9/19.
//  Copyright © 2016年 Mac. All rights reserved.
//

import UIKit


extension UIBarButtonItem{
    
    
    convenience init(title: String,imageName: String? = nil,target: Any?,action: Selector)
    {
        self.init()
        
        let button = UIButton()
        
        if imageName != nil
        {
            
            button.setImage(UIImage(named: imageName!), for: .normal)
            
        }
        
        //添加点击事件
        button.addTarget(target, action: action , for: .touchUpInside)
        
        button.setTitle(title, for: .normal)
        
        button.setTitleColor(UIColor.darkGray, for: .normal)
        
        button.setTitleColor(UIColor.orange, for: .highlighted)
        
        button.titleLabel?.font = UIFont.systemFont(ofSize: 14)
        
        button.sizeToFit()
        
        customView = button
        
        
        
        
    }
}
